package com.example.redisdemon.controller;

import com.example.redisdemon.entity.Book;
import com.example.redisdemon.service.BookService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName BookController
 * @Description TODO
 * @Author leejiliang
 * @DateTime 2020/5/1 10:53 PM
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
public class BookController {

	private final BookService bookService;

	@PostMapping
	public void saveBook(@RequestBody Book book) {
		bookService.saveBook(book);
	}

	@GetMapping
	public Book getBook(@RequestParam("id") Long id) {
		return bookService.getBook(id);
	}

	@DeleteMapping
	public void deleteBook(@RequestParam("id") Long id) {
		bookService.deleteBook(id);
	}
}
